/* eslint-disable no-useless-constructor */
import React from 'react';
export default class MouseRenderProps extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      positionx: 0,
      positiony: 0,
    };
  }
  componentDidMount() {
    const that = this;
    document.addEventListener('mousemove', e => {
      that.setState({
        positionx: e.clientX,
        positiony: e.clientY,
      });
    });
  }

  componentWillUnmount() {
    document.removeEventListener('mousemove', e => {
      console.log(e);
    });
  }

  render() {
    return <div>{this.props.render(this.state)}</div>;
  }
}
